package com.qinhailin.portal.dbm.model;


import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.Model;
import com.qinhailin.common.model.BaseModel;

/**
 * <p>by harrydeep@wardyan.top 2019</p>
 * <p>审核:2019-10-17</p>
 * <p>映射实体类, 使用了反射</p>
 * <p>审核:2019-11-18</p>
 */
public abstract class BaseMappingKit {

	@SuppressWarnings({"unchecked" })
	protected void mapping(ActiveRecordPlugin arp, BaseModel<? extends Model<?>> dao) {
		arp.addMapping(dao.tableName(), dao.primaryKey(), (Class<? extends Model<?>>) dao.getClass());
	}
	
	/**
	 * <p>映射实体类, 格式:</p>
	 * <p>this.mapping(arp, Model.dao())</p>
	 * <p>注意,如果映射出错, 会记录到日志级别fatal中!<br>2019-11-18 因为ADD MAPPING方式改了,不会轻易出错了,因此没有记录日志</p>
	 * <p>审核:2019-11-18</p>
	 * @param arp
	 */
	public abstract void mapping(ActiveRecordPlugin arp);

}
